import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

public class SortReducer extends Reducer<IntWritable, IntWritable, IntWritable, IntWritable> {
    @Override
    protected void reduce(IntWritable key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
        List<Integer> valueList = new ArrayList<Integer>();
        for(IntWritable value : values){
            valueList.add(value.get());
         }
        Collections.sort(valueList);
        for (Integer value : valueList){
            context.write(key,new IntWritable(value));
        }

    }

}
